<?php include "./pc/view/header.inc.htm"; ?>
<div class="container">
    <div class="page-canvas">
        <div class="signin-wrapper">
            <h1>用户登录</h1>
            <form method="POST" id="form" action="user-setpw.htm" class="signin">
                <fieldset>
                    <div class="field">
                        <?php echo $email; ?>
                    </div>
                    <div class="field">
                        <input type="password" maxlength="26" placeholder="新密码" name="password">
                    </div>
                    <div class="field">
                        <input type="password" maxlength="26" placeholder="重复密码" name="password2">
                    </div>
                </fieldset>
                <div class="button">
                    <button type="submit" class="primary-btn" loading-text="正在提交...">
                        完成注册
                    </button>
                </div>
            </form>
        </div>
        <!--TODO QQ暂时注掉-->
        <!--<div class="info">-->
            <!--<p>-->
                <!--您可以直接使用第三方帐号登录-->
                <!--<span class="point">·</span>-->
                <!--<a href="#">QQ登录 »</a>-->
                <!--<span class="point">·</span>-->
                <!--<a href="#">微信登录 »</a>-->
            <!--</p>-->
        <!--</div>-->
    </div>
</div>
<?php include "./pc/view/footer.inc.htm"; ?>

<script>

var referer = $.pdata('referer');
if(!referer) referer = './';

var jform = $('#form');
var jsubmit = jform.find('button[type="submit"]');
var jpassword = jform.find('input[name="password"]');
var jpassword2 = jform.find('input[name="password2"]');
jform.off('submit').on('submit', function() {
//jsubmit.off('click').on('click', function() {
    if(!jpassword.val()) {
        jpassword.popover('请输入密码').focus();
        return false;
    }
    if(jpassword.val() != jpassword2.val()) {
        jpassword2.popover('两次输入的密码不一致').focus();
        return false;
    }
    var postdata = {password: $.md5(jpassword.val())};
    jsubmit.button('loading');
    $.xpost(jform.attr('action'), postdata, function(code, message) {
        if(code == 0) {
            jsubmit.button('注册成功');
            setTimeout(function() { window.location=referer; }, 2000);
        } else if(code == 1) {
            jpassword.popover(message).focus();
            jsubmit.button('reset');
        } else {
            $.alert(message);
            setTimeout(function() {jsubmit.button('reset');}, 1000);
        }
    });
    return false;
});
</script>